<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>掌中游 - 抽奖</title>
<link href="__PUBLIC__/Home/css/choujiang_record.css" rel="stylesheet" />
	<link href="__PUBLIC__/choujiang/css/choujiang.css" rel="stylesheet">
	<script src="__PUBLIC__/choujiang/js/jquery-1.8.3.min.js"></script>
	<script src="__PUBLIC__/choujiang/js/jquery.rotate.min.js"></script>

</head>

<body>
<h1>掌中游 - 抽奖</h1>
<h2 style="color:blue;margin:0 auto;width:80%">【我的当前积分】A账户:<span style='color:red;font-weight:none'>{$jfa}</span>&nbsp;&nbsp;B账户:<span style='color:red;font-weight:none'>{$jfb}</span></h2>
<div id="dowebok">
	<div class="plate">
		<a id="plateBtn" href="javascript:" title="开始抽奖">开始抽奖</a>
	</div>

	<div class="prize">
		<h4>奖品设置</h4>
		<ul>
			<volist name="results" id="jiangpin">
				<li><strong>{$jiangpin.jiangpin_dengji}：</strong>{$jiangpin.jiangpin_name}</li>
			</volist>
		</ul>
		<input type="hidden" id="suiji" value="{$suiji}" />
		<input type="hidden" id="jfa" value="{$jfa}" />
		<input type="hidden" id="jfb" value="{$jfb}" />
	</div>

	<div id="result">
		<p id="resultTxt"></p>
		<a id="resultBtn" href="javascript:" title="关闭">关闭</a>
	</div>
</div>

<h1>自己的抽奖记录</h1>

	<div class="bcon">

		<!-- 代码开始 -->
		<div class="list_lh">
			<ul>
			<foreach name="result" item="vo">
				<li>
					<p>恭喜 {$vo.mobile}<a href="javascript:;" class="btn_lh">{$vo.jiangpin_dengji}</a><em>获得</em></p>
					<p><a href="javascript:;" class="a_blue">{$vo.jiangpin_name}</a><span>{$vo.choujiang_time}</span></p>
				</li>
			</foreach>
			</ul>
		</div>
		<!-- 代码结束 -->
	</div>

<h1>全部中奖记录</h1>

	<div class="bcon">

		<!-- 代码开始 -->
		<div class="list_lh">
			<ul>
			<foreach name="result_all" item="vo">
				<li>
					<p>恭喜 {$vo.mobile}<a href="javascript:;" class="btn_lh">{$vo.jiangpin_dengji}</a><em>获得</em></p>
					<p><a href="javascript:;" class="a_blue">{$vo.jiangpin_name}</a><span>{$vo.choujiang_time}</span></p>
				</li>
			</foreach>
			</ul>
		</div>
		<!-- 代码结束 -->
	</div>

<script>
$(function(){
	var $plateBtn = $('#plateBtn');
	var $result = $('#result');
	var $resultTxt = $('#resultTxt');
	var $resultBtn = $('#resultBtn');

	$plateBtn.click(function(){
		var data = $('#suiji').val();
		var jfa = $('#jfa').val();
		var jfb = $('#jfb').val();
		if(jfa-0+jfb<{$low_jf}){
		alert('对不起，积分不足，快去邀请小伙伴加入掌中游大家庭赚取积分吧！');
		return;
		}
		if(jfa>={$low_jf}){
			$('#jfa').val(jfa-{$low_jf});
		}
		if(jfb>={$low_jf}){
			$('#jfb').val(jfb-{$low_jf});
		}
		
		//data = data[Math.floor(Math.random()*data.length)];
		$.post("{:U('Index/choujiang_add')}",{"data":data},
				function(text){
				console.debug('消息:有个人跑在你前面把奖品拿走了!');
					/*if(text==0) {
						//alert("抽奖失败!");
					}else if(text==1){
						//alert('抽奖成功!');
					}else{
						alert('请登录！');
						//window.location.href="{:U('Public/login')}";
					}*/
					if(text==6){
					   alert('对不起，你的积分不足，快去邀请小伙伴加入掌中游大家庭赚取积分吧！');
					   return;
					}else if(text=='no_login'){
						 alert('请登录！');
						 window.location.href="{:U('Public/login')}";
					   return;
					}else if(text=='888'){
						 alert('你今日的抽奖次数已用完,明天再来吧！');
					   return;
					}
					
					switch(text){
			case 1:
				rotateFunc(1,157,'恭喜你中了 <em>一等奖</em>');
				break;
			case 2:
				rotateFunc(2,65,'恭喜你中了 <em>二等奖</em>');
				break;
			case 3:
				rotateFunc(3,335,'恭喜你中了 <em>三等奖</em>');
				break;
			case 4:
				rotateFunc(4,247,'恭喜你中了 <em>四等奖</em>');
				break;
			case 5:
				rotateFunc(0,203,'恭喜你中了 <em>参与奖</em>');
				break;
			default:
					var x=Math.floor(Math.random()*10);
					//alert(x);
					if(x==1||x==2||x==3){
						rotateFunc(0,290,'谢谢参与，请再接再厉');
					}else if(x==4||x==5||x==6){
						rotateFunc(0,25,'谢谢参与，请再接再厉');
					}else{
						rotateFunc(0,115,'谢谢参与，请再接再厉');
					}

				break;
		}
				},"json");

		/*switch(text){
			case "1":
				rotateFunc(1,157,'恭喜你中了 <em>一等奖</em>');
				break;
			case "2":
				rotateFunc(2,65,'恭喜你中了 <em>二等奖</em>');
				break;
			case "3":
				rotateFunc(3,335,'恭喜你中了 <em>三等奖</em>');
				break;
			case "4":
				rotateFunc(4,247,'恭喜你中了 <em>四等奖</em>');
				break;
			case "5":
				rotateFunc(0,203,'恭喜你中了 <em>参与奖</em>');
				break;
			case "6":
				alert('对不起，你的积分不足，快去邀请小伙伴加入掌中游大家庭赚取积分吧！');
				break;
			default:
					var x=Math.floor(Math.random()*10);
					//alert(x);
					if(x==1||x==2||x==3){
						rotateFunc(0,290,'谢谢参与，请再接再厉');
					}else if(x==4||x==5||x==6){
						rotateFunc(0,25,'谢谢参与，请再接再厉');
					}else{
						rotateFunc(0,115,'谢谢参与，请再接再厉');
					}

				break;
		}*/


		/*
		*一等奖  array(135,180) 2%
		* 二等奖 array(45,90) 5%
		* 三等奖  array(315,360) 8%
		* 四等奖  array(225,270) 10%
		* 参与奖  array(180,225) 15%
		* 谢谢参与  array(270,315),array(0,45),array(90,135) 60%
		*/

		//rotateFunc(0,135,'恭喜你中了 <em>参与奖</em>');
	});



	var rotateFunc = function(awards,angle,text){  //awards:奖项，angle:奖项对应的角度
		$plateBtn.stopRotate();
		$plateBtn.rotate({
			angle: 0,
			duration: 5000,
			animateTo: angle+1440,  //angle是图片上各奖项对应的角度，1440是让指针固定旋转4圈
			callback: function(){
				$resultTxt.html(text);
				$result.show();
			}
		});
	};

	$resultBtn.click(function(){
		$result.hide();
		window.location.reload();
	});

});
</script>

	<script src="__PUBLIC__/Home/js/scroll.js"></script>	
	<script>
	$(function(){
		$('.list_lh li:even').addClass('lieven');
	})
	$(function(){
		$("div.list_lh").myScroll({
			speed:40, //数值越大，速度越慢
			rowHeight:68 //li的高度
		});
	});
	</script>


	<script>
	$(function(){
		$('.list_lh li:even').addClass('lieven');
	})
	$(function(){
		$("div.list_lh").myScroll({
			speed:40, //数值越大，速度越慢
			rowHeight:68 //li的高度
		});
	});
	</script>
</body>
</html>